package com.dev.stream.For;

import com.dev.stream.pojo.Person;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author 戴 骥
 * @date 2021-09-05 16:35
 */
public class MatchStream {
    @Test
    public void matchStream() {
        List<Integer> list = Arrays.asList(7, 6, 9, 3, 8, 2, 1);

        List<Person> personList = new ArrayList<Person>();
        personList.add(new Person("韩梅梅", 8900, 22, "女", "武汉"));
        personList.add(new Person("李磊", 7000, 33, "男", "上海"));
        personList.add(new Person("Lucy", 7800, 44, "女", "北京"));
        personList.add(new Person("狗哥", 8200, 55, "男", "深圳"));
        personList.add(new Person("Lily", 9500, 66, "女", "深圳"));
        personList.add(new Person("Jim", 7900, 77, "男", "深圳"));

        // 是否包含符合特定条件的元素
        boolean b = list.stream().anyMatch(t -> t > 2);

        System.out.println("是否包含年龄为30岁 = " + personList.stream().anyMatch(t -> t.getAge() == 30));


    }
}

